<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
use SplSubject;

class BaseModel extends Model
{
    protected $connection = 'mysql';


    public static function createOne($params)
    {
        $orm = new static();
        foreach ($params as $k => $v) {
            $orm->$k = $v;
        }
        return $orm;
    }

    public static function editOne($where, $params)
    {
        $orm = new static();
        $model = $orm->where($where)->first();

        foreach ($params as $key => $value) {
            $model->$key = $value;
        }
        return $model;
    }

    public function scopeToday()
    {
        return $this->where('created_at', '>=', date('Y-m-d 00:00:00'))->where('created_at', '<=', date('Y-m-d 23:59:59'));
    }


}
